package com.zjdiepu.www.commpent.mapper.base;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.stereotype.Component;

import com.zjdiepu.www.base.core.BaseMapper;
import com.zjdiepu.www.base.enums.type.AttachmentLabel;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.model.base.dto.OtherAttachments;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.util.CachedEnums;
/**
 * 项目名称：dpqc-parent-manager-information <br/> 
 * 类名称：YwBusinessDetailMapper <br/>  
 * 类描述：附件字段转换 <br/>    
 * 创建人：xiongxiaotun <br/> 
 * 创建时间：2017年4月26日 下午1:33:37  <br/>   
 * 修改人：xiongxiaotun <br/> 
 * 修改时间：2017年4月26日 下午1:33:37   <br/>  
 * 修改备注：    <br/> 
 * @version V1.0   <br/>
 */
@Component
public class OtherAttachmentsVoMapper extends BaseMapper<OtherAttachments>{
	@Resource
	private RedisObjectClient redisObjectClient;
	
	@Override
	public void mapper(RedisConnection redisConnection,OtherAttachments m) {
		if(null == m) {
			return;
		}
		String customLabelName = m.getCustomLabelName();
		if(StringUtils.isBlank(customLabelName)) {
			String fileLabel = m.getFileLabel();
			m.setCustomLabelName((String)CachedEnums.getValue(fileLabel, AttachmentLabel.class));
		}
		
		String clientType = m.getClientType();
		SimpleDataDictionary simpleDataDictionary = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), clientType, DataDicType.CLIENT_TYPE.getCode());
		m.setClientTypeDisplay(simpleDataDictionary == null ? "" : simpleDataDictionary.getName());
	}

}
